import Cookies from 'js-cookie'

const TOKEN_KEY = 'Ukyo-Token'

const USER_KEY = 'User-Name'

export function getToken(){
    return Cookies.get(TOKEN_KEY)
}
export function setToken(token){
    return Cookies.set(TOKEN_KEY,token)
}

export function setTokenExpired(token,expired){
    let expires = new Date(new Date().getTime() + (expired-2000));
    return Cookies.set(TOKEN_KEY,token,{
        expires: expires
    })
}
export function removeToken(){
    return Cookies.remove(TOKEN_KEY)
}

export function getUserName(){
    if(getToken()){
        return Cookies.get(USER_KEY)
    }else{
        Cookies.remove(USER_KEY)
        return null
    }

}

export function setUserName(username){
    return Cookies.set(USER_KEY,username)
}

